<template>
  <div class="city">
    <city-header />
    <city-search  :cities="cities" />
    <city-list :hotCities="hotCities" :cities="cities" :changeAlpha="changeAlpha" />
    <city-alphabet :cities="cities" @change="changeAlphaItem" />
  </div>
</template>

<script>
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabet from './components/alphabet'
export default {
  name: 'city',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      hotCities: [],
      cities: {},
      changeAlpha: ''
    }
  },
  methods: {
    changeAlphaItem (letter) {
      this.changeAlpha = letter
    }
  },
  created () {
    this.$nextTick(() => {
      this.Axios.get('/api/city.json')
        .then(res => {
          res = res.data
          if (res.ret && res.data) {
            let data = res.data
            this.hotCities = data.hotCities
            this.cities = data.cities
          }
        })
    })
  }
}
</script>

<style lang="stylus">

</style>
